define("JFLFieldSalese54c2e96Section", [ "ProcessModuleUtilities","ConfigurationConstants"], function(ProcessModuleUtilities,ConfigurationConstants) { return { // Section schema name. entitySchemaName: "JFLFieldSales", // Section view model methods. methods: { // Defines if the menu option is enabled. isCustomActionEnabled: function() { // Attempt to receive the selected record indentifier array var selectedRows = this.get("SelectedRows"); // If the array contains some elements (at least one of the records is selected from the list), // it returns true, otherwise — false. return selectedRows ? (selectedRows.length > 0) : false; }, // Action handler method. Opens the [Contacts] lookup. setFieldSalesRep: function() { // Defining the lookup configuration. var config = { // The [Employee] Schema. entitySchemaName: "Employee", // Multiple selection is disabled. multiSelect: false, // The displayed column — [Name]. columns: ["Name"] }; // Opening of the lookup with certain configuration and call-back function that is triggered // after you click [Select]. this.openLookup(config, this.lookupCallback, this); }, // Sets the lookup selected contact as the owner // for the selected list records. lookupCallback: function(args) { // The selected lookup record identifier. var activeRowId; // Receiving of the lookup selected records. var lookupSelectedRows = args.selectedRows.getItems(); if (lookupSelectedRows && lookupSelectedRows.length > 0) { // Receiving of the first lookup selected record Id. activeRowId = lookupSelectedRows[0].Id; } // Receiving of the selected record identifier array. var selectedRows = this.get("SelectedRows"); // The procession starts if at least one record is selected from the list and the owner is selected // in the lookup. if ((selectedRows.length > 0) && activeRowId) { // Creation of the batch query class instance. var batchQuery = this.Ext.create("Terrasoft.BatchQuery"); // Update of each selected record. /*selectedRows.forEach(function(selectedRowId) { // Creation of the UpdateQuery class instance with the Activity root schema. var update = this.Ext.create("Terrasoft.UpdateQuery", { rootSchemaName: "JFLFieldSales" }); var args = { "sysProcessName": "JFLProcess_dfe4cdd", "parameters": { ProcessSchemaParameter1:selectedRowId }, }; ProcessModuleUtilities.executeProcess(args); // Applying filter to determine the record for update. update.enablePrimaryColumnFilter(selectedRowId); // The [Owner] column is populated with the value that equals to // the lookup selected contact id. update.setParameterValue("JFLFieldSalesRep", activeRowId, this.Terrasoft.DataValueType.GUID); // Adding a record update query to the batch query. batchQuery.add(update); }, this);*/ var args3 = { "sysProcessName": "JFLProcess_20776c6", "parameters": { ProcessSchemaParameter1:selectedRows }, }; ProcessModuleUtilities.executeProcess(args3); // Batch query to the server. batchQuery.execute(function() { // Record list update. this.reloadGridData(); }, this); } }, // Overriding the base virtual method, returning the section action collection. getSectionActions: function() { // Calling of the parent method implementation, // returning the initialized section action collection. var actionMenuItems = this.callParent(arguments); // Adding separator line. actionMenuItems.addItem(this.getButtonMenuItem({ Type: "Terrasoft.MenuSeparator", Caption: "" })); // Adding a menu option to the section action list. actionMenuItems.addItem(this.getButtonMenuItem({ // Binding the menu option title to the localized schema string. "Caption": { bindTo: "Resources.Strings.SetFieldSalesRepCaption" }, // Binding of the action handler method. "Click": { bindTo: "setFieldSalesRep" }, // Binding the menu option enable property to the value that returns the isCustomActionEnabled method. "Enabled": { bindTo: "isCustomActionEnabled" }, // Multiselection mode enabling. "IsEnabledForSelectedAll": true })); actionMenuItems.addItem(this.getButtonMenuItem({ "Caption": {bindTo: "Resources.Strings.MultiplyChangeAction"}, "Click": {bindTo: "showDateInfo"}, "Enabled": {bindTo: "isCustomActionEnabled"} })); // Returning of the added section action collection. return actionMenuItems; }, showDateInfo: function() { Terrasoft.utils.inputBox("Set Visit Date for update", function(result, arg) { if (result === Terrasoft.MessageBoxButtons.YES.returnCode) { var date = arg.date.value; var autoIds = this.getSelectedItems(); this.updateDate(function(context, result) { }, autoIds, date); } }, [{ className: "Terrasoft.Button", caption: "OK", returnCode: "yes" }, "cancel"], this, { date: { dataValueType: Terrasoft.DataValueType.DATE, caption: "Visit Date", customConfig: { className: "Terrasoft.DateEdit", height: "17px" } }, }, { defaultButton: 0, style: { borderStyle: "ts-messagebox-border-style-blue ts-messagebox-border-no-header", buttonStyle: "blue" } } ); }, updateDate: function(callback, autoIds, date) { var update = Ext.create("Terrasoft.UpdateQuery", { rootSchemaName: "JFLFieldSales" }); var filters = Terrasoft.createFilterGroup(); filters.logicalOperation = Terrasoft.LogicalOperatorType.OR; autoIds.forEach(function(item) { var productIdFilter = update.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "Id", item); filters.add("ProductIdFilter" + item, productIdFilter); }, this); update.filters.add(filters); if (date) { update.setParameterValue("JFLAssignmentDate", date, Terrasoft.DataValueType.Date); // update.setParameterValue("JFLAssignmentDate", time, Terrasoft.DataValueType.Date); } update.execute(function(result) { callback.call(this, result); }, this); } } }; });